package com.fyyg.common.sms.yimei;

import java.net.URLEncoder;

/**
 * 亿美短信接口
 * @author XLM  2016年3月22日
 *
 */
public class YiMeiSendMessage {

	public static String cdkey = "8SDK-EMY-6699-RFWMS";	// 软件序列号,请通过亿美销售人员获取
	public static String key = "168873";				// 序列号首次激活时自己设定
	public static String password = "168873";			// 密码,请通过亿美销售人员获取
	public static String baseUrl = "http://hprpt2.eucp.b2m.cn:8080/sdkproxy/";
	public static String sign = ""; //"【众筹益购】";
	public static String seqid = "8888888888";
//	public static String addserial = "8888";
	
	
	/**
	 * 普通短信通道
	 * @param phone
	 * @param message
	 */
	public static void sendMessage(String phone,String message){
		try {
			message = sign+message;
			message = URLEncoder.encode(message, "UTF-8");
			String param = "cdkey=" + cdkey + "&password=" + key + "&phone=" + phone + "&message=" + message +"&seqid=" + seqid;
			String url = baseUrl + "sendsms.action";
			String ret = SDKHttpClient.sendSMS(url, param);
			System.out.println("发送结果:" + ret);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	/**
	 * 定时短信通道
	 * @param phone
	 * @param message
	 * @param sendtime  短信发送时间，时间格式为 yyyymmddhhnnss
	 */
	public static void timingMessage(String phone,String message,String sendtime){
		try {
			message = sign+message;
			message = URLEncoder.encode(message, "UTF-8");
			String param = "cdkey=" + cdkey + "&password=" + key + "&phone=" + phone + "&message=" + message + "&sendtime=" + sendtime+"&seqid=" + seqid;
			String url = baseUrl + "sendsms.action";
			String ret = SDKHttpClient.sendSMS(url, param);
			System.out.println("发送结果:" + ret);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String[] args) {
//		System.out.println(YXDate.myfromDate1(YXDate.getTime()));
		timingMessage("13202288781", "卡密：","4093-0614-0934-94A4");
	}
	
}
